{% extends "base.html" %}
{% load static %}
{% load gravatar %}
{% load render_thermo %}
{% load databasefilters %}



{% block title %}
{% if section != '' %}
RMG Thermodynamics {{ section|title }}
{% else %}
RMG Thermodynamics Database
{% endif %}
{% endblock %}

{% block extrahead %}
<style>
table.thermoEntryData {
    text-align: center;
    margin-bottom: 1em;
}

table.thermoEntryData td.key {
    font-weight: bold;
    text-align: right;
}

table.thermoEntryData td.equals {
    text-align: center;
}

table.thermoEntryData td.value {
    text-align: left;
}

table.thermoEntryData td.reference p {
    margin: 0px;
}
</style>

<script src="https://code.highcharts.com/6/highcharts.js"></script>
<script src="{% static 'js/highcharts.theme.js' %}" type="text/javascript"></script>

<script type="text/javascript">
jQuery(document).ready(function() {

    var Cpseries = new Array();
    var Hseries = new Array();
    var Sseries = new Array();
    var Gseries = new Array();

    {{ thermo|get_thermo_data:user }}
    {% include "thermoModel.js" %}
    
    MathJax.Hub.Queue(function() {
        plotHeatCapacity('plotCp', Cpseries);
        plotEnthalpy('plotH', Hseries);
        plotEntropy('plotS', Sseries);
        plotFreeEnergy('plotG', Gseries);
    });

});
</script>
{% endblock %}

{% block navbar_items %}
<li><a href="{% url 'database:index' %}">Database</a></li>
<li><a href="{% url 'database:thermo' %}">Thermodynamics</a></li>
<li><a href="{% url 'database:thermo' section=section %}">{{ section|title }}</a></li>
<li><a href="{% url 'database:thermo' section=section subsection=subsection %}">{{ databaseName }}</a></li>
{% if entry.index and entry.index != -1 %}<li><a href="{% url 'database:thermo-entry' section=section subsection=subsection index=entry.index %}">{{ entry.index }}. {{ entry.label }}</a></li>{% endif %}
{% endblock %}

{% block sidebar_items %}
{% endblock %}

{% block page_title %}{% if entry.index %}{{ entry.index }}. {{ entry.label }}{% endif %}{% endblock %}

{% block page_body %}

<h2>Structure</h2>
<p>
{% if structure == '' %}
No structure given.
{% else %}
{{ structure|safe }}
{% endif %}
</p>

<h2>Thermodynamic Data</h2>
{% ifequal thermo.0 'Link' %}
<table class="thermoEntryData">
<tr>
    <td class="key">Link:</td>
    <td class="value"><a href="{% url 'database:thermo-entry' section=section subsection=subsection index=thermo.1 %}">{{ entry.data }}</a></td>
</tr>
</table>
{% else %}
{{ thermo|render_thermo_math:user }}
{% endifequal %}

{% if nasa_string %}
<br/>
CHEMKIN format NASA Polynomial:
<br/>
<font face='courier'>{{ nasa_string|renderNASA }}</font>
<P>
{% endif %}
{% if thermo|get_thermo_data:user %}
<div id="plotCp" style="width: 500px; height: 300px; margin: auto;"></div>
<div id="plotH" style="width: 500px; height: 300px; margin: auto;"></div>
<div id="plotS" style="width: 500px; height: 300px; margin: auto;"></div>
<div id="plotG" style="width: 500px; height: 300px; margin: auto;"></div>
{% endif %}

<h2>Reference</h2>
{% include "reference.html" %}


<br/>

{% if entry.index and entry.index != -1 %}
If you noticed a mistake or have better data, then edit this entry here: <a href="{% url 'database:thermo-entry-edit' section=section subsection=subsection index=entry.index %}"><button type="button">Edit entry</button></a>.
{% endif %}
{% if user.is_authenticated %}
You are logged in as {{ user.get_full_name }}</a> 
{% else %}
You must <a href="{% url 'login' %}?next={{ request.path }}">log in first.</a>
{% endif %}
<br/>

{% endblock %}
